#ifndef __ENCODER_H
#define __ENCODER_H

#include "main.h"

#define AS5600_I2C_HANDLE hi2c1

#define I2C_TIME_OUT_BASE   10
#define I2C_TIME_OUT_BYTE   1

#define AS5600_RAW_ADDR    0x36
#define AS5600_ADDR        (AS5600_RAW_ADDR << 1)
#define AS5600_WRITE_ADDR  (AS5600_RAW_ADDR << 1)
#define AS5600_READ_ADDR   ((AS5600_RAW_ADDR << 1) | 1)

extern int direction;

#define AS5600_RESOLUTION 4096 //12bit Resolution 

#define AS5600_RAW_ANGLE_REGISTER  0x0C
#define AS5600_RAW_ANGLE_REGISTER_lo  0x0D

float as5600GetRawAngle(void);

void as5600Init(void);

void full_rotation(int num);

float full_angle(void);

float get_velocity(float angle);
void AS5600_update();
float AS5600_get_raw();
float AS5600_get_full();
float AS5600_get_vel();


#endif
